
package com.jesse.base;

import com.jesse.main.R;
import com.jesse.util.ViewUtil;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;

public class BaseActivity extends Activity {

	private ActivityUtil activityUtil = new ActivityUtil();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		activityUtil.onCreate(this);
	}
	
	@Override
	protected void onResume() {
        super.onResume();
        activityUtil.onResume(this);
        initLayout();
		initActionBar();
		initData();
    }
	 
	/**
	 * Hooks 初始化布局
	 */
	public void initLayout() {
		
	}
	
	/**
	 * Hooks 初始化ActionBar
	 */
	public void initActionBar() {
		
	}
	
	/**
	 * Hooks 初始化数据
	 */
	public void initData() {
		
	}
	
	/**
	 * Hooks 初始化新手引导
	 */
	public void checkGuider() {
		
	}
	
	//手勢开关
	public boolean isGestrue() {
		return activityUtil.isGestrue();
	}
	
	public void setGestrue(boolean gestrue) {
		activityUtil.setGestrue(gestrue);
	}
	
	@Override
	public boolean dispatchTouchEvent(MotionEvent event) {
		if (activityUtil.dispatchTouchEvent(this, event)) {
			finish();
			return true;
		}
		return super.dispatchTouchEvent(event);
	}
	
	public void finish() {
		activityUtil.finish(this);
		super.finish();
		overridePendingTransition(0, R.anim.out_to_left);
	}
	
	@Override
    protected void onDestroy() {
		activityUtil.onDestroy(this);
        super.onDestroy();
    }
}
